import {imageUrl} from "../../utils/imageutil"

Page({
  data: {
    imageUrl,
    
    nav_curr: '',

    name: '',

    shopInfo: wx.getStorageSync('merchant').admin,
    list: [],
    page: 1,
    limit: 10,
    flag: true,
    showmask:false,
    checkList:[],
    id:'',
  },
  onLoad: function (options) {
    this.setData({
      id:options.id,
      money:options.money
    })
    this.getauntList()
  },
  onPullDownRefresh() {
    this.setData({
      page: 1,
      flag: true,
      list: [],
      nav_curr:''
    })
    this.getauntList()
  },
  onReachBottom() {
    this.getauntList()
  },
  getauntList() {
    let data = {
      page: this.data.page,
      pagesize: this.data.limit,
      keys:this.data.name
    }
    if (!this.data.flag) {
      return
    }
    this.setData({
      flag: false
    })
    getApp().globalData.gets('/api/ouyoung/user/getuserlist', data).then(res => {
      wx.stopPullDownRefresh()
      if (res.data.data.data.length == 0) {
        this.setData({
          flag: false
        })
      } else {
        let arr = this.data.list.concat(res.data.data.data);
        this.setData({
          list: arr,
          page: this.data.page + 1,
          flag: true
        })
      }
    })
  },
  change_user(e) {
    this.setData({
      nav_curr:e.detail.value
    })
  },
  bottomTaps() {
    if(!this.data.nav_curr){
      wx.showToast({
        title: '请先选择用户',
        icon:'none'
      })
      return
    }
    wx.setStorageSync('store_to_user', this.data.list[this.data.nav_curr])
    wx.navigateBack({
      delta: 1,
    })
  },
  
  catchtap(){},

  change_nav_curr(e) {
    this.setData({
      nav_curr: e.currentTarget.dataset.type,
    })
  },

  change_name(e){
    this.setData({
      name:e.detail.value,
      list: [],
      page: 1,
      flag: true,
      nav_curr:''
    })
    this.getauntList()
  },

})